﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace Mapper
{
    public abstract class PropertyList
    {                   
        private List<PropertyInfo> _properties;

        public PropertyList()
        {
            this._properties = new List<PropertyInfo>();
        }
        public PropertyList(Type type, params string[] properties)
        {
            if (this._properties == null)
                this._properties = new List<PropertyInfo>();
            this.Add(type, properties);
        }
        public void Add(Type type, params string[] properties)
        {
            foreach (string s in properties)
            {
                PropertyInfo property = this.getProperty(type, s);
                if (property == null)
                {
                    throw new Exception("Property not found: " + type.FullName + "." + s);
                }
                this._properties.Add(property);
            }
        }
        private PropertyInfo getProperty(Type type, string property)
        {            
            return type.GetProperty(property, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);            
        }

        
        
    }
}
